<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"

>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<div sec:authorize="!isAuthenticated()">
    <h2 align="center">
        <a th:href="@{/userlogin}">
            <button>登录</button>
        </a>
        <a th:href="@{/user/toregist}">
            <button>注册</button>
        </a>
    </h2>
</div>
<div sec:authorize="isAuthenticated()">
    <h2 align="center">
        <div sec:authentication="name"/>
        xxx，你好，你拥有的角色有
        <div sec:authentication="principal.authorities">x</div>
    </h2>
    <form th:action="@{/logout}" method="post">
        <input type="submit" value="退出">
    </form>
</div>
<div sec:authorize="hasRole('VIP1')">
    <h3>普通武功秘籍</h3>
    <ul>
        <li><a th:href="@{/level1/1}">罗汉拳</a></li>
        <li><a th:href="@{/level1/2}">武当长拳</a></li>
        <li><a th:href="@{/level1/3}">全真剑法</a></li>
    </ul>
</div>

<div sec:authorize="hasRole('VIP2')">
    <h3>高级武功秘籍</h3>
    <ul>
        <li><a th:href="@{/level2/1}">太极拳</a></li>
        <li><a th:href="@{/level2/2}">七伤拳</a></li>
        <li><a th:href="@{/level2/3}">梯云纵</a></li>
    </ul>
</div>

<div sec:authorize="hasRole('VIP3')">
    <h3>绝世武功秘籍</h3>
    <ul>
        <li><a th:href="@{/level3/1}">葵花宝典</a></li>
        <li><a th:href="@{/level3/2}">龟派气功</a></li>
        <li><a th:href="@{/level3/3}">独孤九剑</a></li>
    </ul>
</div>
<body>
<a href="toadd">
    <button>添加</button>
</a>
<table border="1">
    <tr>
        <td>id</td>
        <td>标题</td>
        <td>分类</td>
        <td>状态</td>
        <td>操作</td>
    </tr>
    <tr th:each="user : ${ulist}">
        <td th:text="${user.id}">id</td>
        <td th:text="${user.title}">name</td>
        <td th:text="${user.name}">gname</td>
        <td th:text="${user.state}">
            <!--  <input type="radio" name="state" th:value="${goods.state}" th:checked="${'1' eq goods.state}">上架
              <input type="radio" name="state" th:value="${goods.state}" th:checked="${'2' eq goods.state}">下架-->
        </td>
        <td>
            <a th:href="@{'toupdate?id='+${user.id}}">
                <button>修改</button>
            </a>
            <a th:href="@{'todel?id='+${user.id}}">
                <button>删除</button>
            </a>
        </td>
    </tr>
</table>
</body>
</html>